package com.tianji.remark.Utils;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * redis缓存点赞次数定期持久化到mysql的定时任务
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class LikedTimesChenckTask {
    private final ILikedRecordService likedRecordService;
    private static final List<String> BIZ_TYPES = List.of("QA","NOTE");
    private static final Integer MAX_BIZ_SIZE = 30;
    @Scheduled(fixedDelay = 20000)
    public void likedTimesTask() {
        log.info("定时任务开始执行");
        for (String bizType : BIZ_TYPES) {
            likedRecordService.checkLikedTimesAndSendMsg(bizType,MAX_BIZ_SIZE);
        }
    }
}
